<?php

 class __kernel_system {
 
        var $urls = array(
                "autorun" => "autorun"
        );
 
        function autorun() {
                $this->filterByArgsMap();
        }
        
        function filterByArgsMap_part2($val, $item) {
                    if($val[0] == "int")    $val = new KT_system_int($item);
                elseif($val[0] == "double") $val = new KT_system_double($item);
                elseif($val[0] == "string") $val = new KT_system_string($item);
                else $val = false;
                
                return $val;
        }
        
        function filterByArgsMap() {
                $page = new KT_start_pageName($_GET['m'], $_GET['p']);

                if($page->get() == '') { return false; }
       
                $MT = "MT_{$_GET['m']}_argsMap_".$page->get();
                
                if(class_exists($MT)) {

                        __kernel_start::onlyStartModule($_GET['m']);
                        global $init;
                        
                        __kernel_start::si($_GET['m'])->argsMap = new $MT();

                        if(is_array(__kernel_start::si($_GET['m'])->argsMap->GET)) {
                                foreach($_GET as $key=>$item) {

                                        if($key != "m" && $key != "p" && is_array(__kernel_start::si($_GET['m'])->argsMap->GET[$key])) {

                                                $val = __kernel_start::si($_GET['m'])->argsMap->GET[$key];
                                                $val = $this->filterByArgsMap_part2($val, $item);
                                                
                                                if($val != false) {
                                                        __kernel_start::si($_GET['m'])->argsMap->GET[$key] = $val->get();
                                                        unset($_GET[$key]);
                                                }
                                        }
                                }
                        }
                        
                        if(is_array(__kernel_start::si($_GET['m'])->argsMap->POST)) {
                                foreach($_GET as $key=>$item) {

                                        if($key != "m" && $key != "p" && is_array(__kernel_start::si($_GET['m'])->argsMap->POST[$key])) {

                                                $val = __kernel_start::si($_GET['m'])->argsMap->POST[$key];
                                                $val = $this->filterByArgsMap_part2($val, $item);
                                                
                                                if($val != false) {
                                                        __kernel_start::si($_GET['m'])->argsMap->POST[$key] = $val->get();
                                                        unset($_POST[$key]);
                                                }
                                        }
                                }
                        }
                } else {
                        return false;
                }
               
        }
 
 }

?>
